import { ActionTree, GetterTree, MutationTree, Module } from 'vuex'

declare interface swaggerStore {
  info: string | null
  path: string | null
  menus: any
  headers: any
  theme: any
}

const swaggerStoreState: swaggerStore = {
  info: null,
  path: null,
  menus: null,
  headers: null,
  theme: null
}

const swaggerStoreGetters: GetterTree<swaggerStore, any> = {
  info: state => state.info,
  path: state => state.path,
  menus: state => state.menus,
  headers: state => state.headers,
  theme: state => state.theme
}

const swaggerStoreMutations: MutationTree<swaggerStore> = {
  swaggerPath(state, payload) {
    state.path = payload
  },
  swaggerInfo(state, payload) {
    state.info = payload
  },
  menus(state, payload) {
    state.menus = payload
  },
  headers(state, payload) {
    state.headers = payload
  },
  theme(state, payload) {
    state.theme = payload
  }
}

const swaggerStoreActions: ActionTree<swaggerStore, any> = {
  path({ commit }, param) {
    commit('swaggerPath', param)
  },
  info({ commit }, param) {
    commit('swaggerInfo', param)
  },
  menus({ commit }, param) {
    commit('menus', param)
  },
  headers({ commit }, param) {
    commit('headers', param)
  },
  theme({ commit }, param) {
    commit('theme', param)
  }
}

const swaggerModule: Module<swaggerStore, any> = {
  state: swaggerStoreState,
  getters: swaggerStoreGetters,
  mutations: swaggerStoreMutations,
  actions: swaggerStoreActions,
  namespaced: true
}

export default swaggerModule
